﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Wicresoft.UnifyShow.Business;
using Microsoft.Practices.Unity;

namespace Wicresoft.UnifyShow.Portal.Controllers
{
    public class AdminOtherController : BaseController
    {


        private IUser_X user;
        private IConfiguration configuration;

        protected override void Dispose(bool disposing)
        {
            ((IDisposable)user).Dispose();
            ((IDisposable)configuration).Dispose();
        }

        [InjectionConstructor]
        public AdminOtherController(IUser_X user, IConfiguration configuration)
        {
            this.user = user;
            this.configuration = configuration;
        }

        //
        // GET: /AdminOther/

        public ActionResult Index()
        {
            base.SetRoles(user);
            if (!IsConfigAdmin) return new HttpStatusCodeResult(403);

            ViewBag.sortAsc = int.Parse(configuration.GetValueByKey("homepage_system_sort_desc"));

            return View();
        }

        [HttpPost]
        public ActionResult ChangeKey(string key, string value)
        {
            configuration.UpdateKey(key, value);

            return new EmptyResult();
        }

    }
}
